package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.FirstMenuInsertCommon;
import com.hangxiang.approval.common.FirstMenuUpdateCommon;
import com.hangxiang.approval.common.IntegerCommon;
import com.hangxiang.approval.common.ResultBean;
import com.hangxiang.approval.service.FirstMenuService;
import com.hangxiang.approval.vo.FirstMenuVo;
import com.hangxiang.approval.vo.MenuListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (FirstMenu)表控制层
 *
 * @author makejava
 * @since 2020-11-25 20:03:44
 */
@RestController
@RequestMapping("firstMenu")
@Api(tags = "一级菜单相关功能")
public class FirstMenuController {
    /**
     * 服务对象
     */
    @Resource
    private FirstMenuService firstMenuService;

    /**
     * 通过主键查询单条数据
     *
     * @param
     * @return 单条数据
     */
    @PostMapping("selectAll")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectAll() {
        MenuListVo firstMenuVoList=firstMenuService.selectAll();
        return ResultBean.success(firstMenuVoList);
    }

    /**
     * 新增数据
     *
     * @param firstMenuInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertFirstMenu")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insertFirstMenu(@RequestBody @Validated FirstMenuInsertCommon firstMenuInsertCommon) {
        return ResultBean.success(firstMenuService.insertFirstMenu(firstMenuInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param firstMenuUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateFirstMenu")
    @ApiOperation(value = "修改数据")
    @ResponseBody
    public ResultBean updateFirstMenu(@RequestBody @Validated FirstMenuUpdateCommon firstMenuUpdateCommon) {
        return ResultBean.success(firstMenuService.updateFirstMenu(firstMenuUpdateCommon));
    }


}